package com.mfin.bs.services;

import com.mfin.bs.mgr.impl.TransactionManager;
import com.mfin.bs.mgr.interfaces.ICustomerInformationManager;
import com.mfin.bs.mgr.interfaces.ITransactionManager;
import com.mfin.vo.CustomerVO;
import com.mfin.vo.PartnerVO;

public class CustomerServicesImpl extends BaseImpl implements ICustomerServices {

	@Override
	public CustomerVO getCustomer(CustomerVO customer) {

		ITransactionManager transaction = new TransactionManager();
		transaction.beginTransaction();

		ICustomerInformationManager customerInformationManager = getCustomerInformationManager(transaction
				.getPersistenceGovernor());
		CustomerVO updatedCustomer = customerInformationManager
				.getCustomer(customer);

		transaction.commitTransaction();
		return updatedCustomer;
	}

	@Override
	public CustomerVO updateCustomer(CustomerVO customer) {

		ITransactionManager transaction = new TransactionManager();
		transaction.beginTransaction();

		ICustomerInformationManager customerInformationManager = getCustomerInformationManager(transaction
				.getPersistenceGovernor());
		CustomerVO updatedCustomer = customerInformationManager
				.updateCustomer(customer);

		transaction.commitTransaction();
		return updatedCustomer;
	}

	@Override
	public PartnerVO getPartner(PartnerVO partnerVO) {
		ITransactionManager transaction = new TransactionManager();
		transaction.beginTransaction();

		ICustomerInformationManager customerInformationManager = getCustomerInformationManager(transaction
				.getPersistenceGovernor());
		PartnerVO updatedPartner = customerInformationManager
				.getPartner(partnerVO);

		transaction.commitTransaction();
		return updatedPartner;
	}

	@Override
	public PartnerVO updatePartner(PartnerVO partnerVO) {
		ITransactionManager transaction = new TransactionManager();
		transaction.beginTransaction();

		ICustomerInformationManager customerInformationManager = getCustomerInformationManager(transaction
				.getPersistenceGovernor());
		PartnerVO updatedPartner = customerInformationManager
				.updatePartner(partnerVO);

		transaction.commitTransaction();
		return updatedPartner;
	}
}
